package com.example.a17376052_wcp_finaltest.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

import com.example.a17376052_wcp_finaltest.MainActivity;
import com.example.a17376052_wcp_finaltest.R;
import com.example.a17376052_wcp_finaltest.TitleActivity;

import java.util.ArrayList;
import java.util.List;

import adapter.FruitAdapter;
import entire.Fruit;

public class Fragment_2 extends Fragment {
    private ListView fruitListView;
    private List<Fruit> fruitList = new ArrayList<Fruit>();

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        View view = inflater.inflate(R.layout.fragment_2, null);


        fruitListView = (ListView) view.findViewById(R.id.fruitListView);

        fruitList.add(new Fruit("串串香大锅肉", R.mipmap.wai));
        fruitList.add(new Fruit("菲力牛排澳洲黑椒牛排", R.mipmap.wdi));
        fruitList.add(new Fruit("苟妈妈香辣掌中宝鸡脆骨", R.mipmap.wei));
        fruitList.add(new Fruit("糖醋蒜末藕片", R.mipmap.wfi));
        fruitList.add(new Fruit("澳洲羊排黑椒羊排", R.mipmap.wsi));
        fruitList.add(new Fruit("东海野生琵琶虾渔船直冻九齿扇贝", R.mipmap.wti));
        fruitList.add(new Fruit("KFC大块鸡肉卷配冰美式", R.mipmap.wxi));
        fruitList.add(new Fruit("鲜活皇帝蟹进口野生澳洲大螃蟹海鲜水产超特大帝王蟹", R.mipmap.wyi));
        fruitList.add(new Fruit("饭后甜品香芋卷", R.mipmap.wpi));

        FruitAdapter adapter = new FruitAdapter(getActivity(), R.layout.fruit_item,fruitList);
        fruitListView.setAdapter(adapter);

        fruitListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Toast.makeText(getActivity(),"原来你也喜欢美食鸭"+position,Toast.LENGTH_SHORT).show();
                Intent intent=new Intent(getActivity(),Main4Activity.class);
                startActivity(intent);

            }
        });
        return view;
    }
}
